//
//  KDAccountTool.m
//  警用舆情平台
//
//  Created by 魏强 on 15/5/12.
//  Copyright (c) 2015年 魏强. All rights reserved.
//
// 账号的存储路径
#define KDAccountPath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.archive"]
#define KDRolePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"role.archive"]
#import "KDAccountTool.h"
#import "KDAccount.h"
#import "KDRole.h"
@implementation KDAccountTool
//SingletonM(AccountTool);
/**
 *  存储账号信息
 *
 *  @param account 账号模型
 */
+ (void)saveAccount:(KDAccount *)account
{
    // 自定义对象的存储必须用NSKeyedArchiver，不再有什么writeToFile方法
    [NSKeyedArchiver archiveRootObject:account toFile:KDAccountPath];
}
+ (KDAccount *)account
{
    // 加载模型
    KDAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:KDAccountPath];
    return account;
}
+ (void)saveRole:(KDRole *)role
{
    // 自定义对象的存储必须用NSKeyedArchiver，不再有什么writeToFile方法
    [NSKeyedArchiver archiveRootObject:role toFile:KDRolePath];
}

+ (KDRole *)role{
    KDRole *role = [NSKeyedUnarchiver unarchiveObjectWithFile:KDRolePath];
    return role;
}
@end
